//
//  MYAboutGMineView.swift
//  MYDoctor
//
//  Created by 小火科技 on 2024/4/8.
//

import UIKit

class MYGAboutMineView: UIView {
    var selectTypeBlock:((_ index:Int)->Void)?
    private var hNum:UILabel?
    private var hsNum:UILabel?
    private var h1Num:UILabel?
    private var hs1Num:UILabel?
    
    var model:MYGAboutGDotorModel? {
        didSet {
            guard let item = model else {return}
            
            
            if let data = item.introduction.data(using: .utf8), let attr = try? NSAttributedString(
                data: data,
                options: [
                    .documentType: NSAttributedString.DocumentType.html,
                    .characterEncoding: String.Encoding.utf8.rawValue
                ],
                documentAttributes: nil
                    
            ) {
                
                hisIntroduceLabel.attributedText = attr
            }
            
            
//            hisIntroduceLabel.text = item.introduction
            hisZhuanyeLabel.text = item.skilled
            hisZhuanyeLabel1.text = item.skilled
            
            hNum!.rz.colorfulConfer { confer in
                confer.text("\(item.clinicalExperiments)")?.textColor(.rgba(24, 24, 24, 1)).font(.medium(14))
                confer.text(" 例")?.textColor(.rgba(162, 162, 162, 1)).font(.regular(12))
            }
            
            hsNum!.rz.colorfulConfer { confer in
                confer.text("\(item.clinicalExperiments)")?.textColor(.rgba(24, 24, 24, 1)).font(.medium(14))
                confer.text(" 例")?.textColor(.rgba(162, 162, 162, 1)).font(.regular(12))
            }
            
            h1Num!.rz.colorfulConfer { confer in
                confer.text("\(item.clinicalExperiments)")?.textColor(.rgba(24, 24, 24, 1)).font(.medium(14))
                confer.text(" 例")?.textColor(.rgba(162, 162, 162, 1)).font(.regular(12))
            }
            
            hs1Num!.rz.colorfulConfer { confer in
                confer.text("\(item.clinicalExperiments)")?.textColor(.rgba(24, 24, 24, 1)).font(.medium(14))
                confer.text(" 例")?.textColor(.rgba(162, 162, 162, 1)).font(.regular(12))
            }
        }
        
    }
    
    func reloadView(index:Int){
        var x :CGFloat = 0
        if index == 2 {
            x = screenWidth
        }else if index == 3 {
            x = screenWidth * 2
        }
        bottomScView.setContentOffset(CGPoint(x: x, y: 0), animated: true)
        
    }
    
    // MARK: - init
    override init(frame: CGRect) {
        super.init(frame: frame)
        configUI()
    }
 
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

    
    func configUI(){
        
        addSubview(bottomScView)
        bottomScView.contentSize = CGSize(width: 3*screenWidth, height: 1000)
        bottomScView.snp.makeConstraints { make in
            make.top.left.bottom.right.equalToSuperview()
        }
        bottomScView.addSubview(bottomContainerView)
        bottomContainerView.snp.makeConstraints { make in
            make.edges.equalToSuperview()
            make.width.equalTo(screenWidth*3)
            make.height.equalTo(0)
        }
        // 1
        bottomContainerView.addSubview(hisIntroduceView)
        hisIntroduceView.snp.makeConstraints { make in
            make.left.top.equalToSuperview()
            make.height.equalTo(SCALEWIDTH(50))
            make.width.equalTo(screenWidth)
        }
        bottomContainerView.addSubview(hisIntroduceLabel)
        hisIntroduceLabel.snp.makeConstraints { make in
            make.left.equalToSuperview().offset(SCALEWIDTH(42.5))
            make.top.equalTo(hisIntroduceView.snp.bottom)
            make.width.equalTo(screenWidth - SCALEWIDTH(85))
        }
        
        //layoutIfNeeded()
//        bottomScView.snp.updateConstraints { make in
//            make.height.equalTo(hisIntroduceLabel.height + SCALEWIDTH(50) + SCALEWIDTH(338))
//        }
//        bottomContainerView.snp.updateConstraints { make in
//            make.height.equalTo(hisIntroduceLabel.height + SCALEWIDTH(50) + SCALEWIDTH(338))
//        }

        bottomContainerView.addSubview(hisZhuanyeView1)
        hisZhuanyeView1.snp.makeConstraints { make in
            make.top.equalTo(hisIntroduceLabel.snp.bottom)
            make.left.equalToSuperview()
            make.height.equalTo(SCALEWIDTH(50))
            make.width.equalTo(screenWidth)
        }
        bottomContainerView.addSubview(hisZhuanyeLabel1)
        hisZhuanyeLabel1.snp.makeConstraints { make in
            make.left.equalToSuperview().offset(SCALEWIDTH(42.5))
            make.top.equalTo(hisZhuanyeView1.snp.bottom)
            make.width.equalTo(screenWidth - SCALEWIDTH(85))
        }
        
        bottomContainerView.addSubview(hisTestView2)
        bottomContainerView.addSubview(testingView1)
        bottomContainerView.addSubview(testedView1)
        
        hisTestView2.snp.makeConstraints { make in
            make.top.equalTo(hisZhuanyeLabel1.snp.bottom)
            make.left.equalToSuperview()
            make.height.equalTo(SCALEWIDTH(50))
            make.width.equalTo(screenWidth)
        }
        testingView1.snp.makeConstraints { make in
            make.top.equalTo(hisTestView2.snp.bottom)
            make.left.equalToSuperview().offset(SCALEWIDTH(42.5))
            make.width.equalTo(screenWidth - 85)
            make.height.equalTo(SCALEWIDTH(70.5))
        }
        testedView1.snp.makeConstraints { make in
            make.top.equalTo(testingView1.snp.bottom).offset(SCALEWIDTH(15))
            make.left.width.equalTo(testingView1 )
            make.height.equalTo(SCALEWIDTH(70.5))
        }
        bottomContainerView.addSubview(button)
        button.snp.makeConstraints { make in
            make.top.equalTo(testingView1.snp.bottom).offset(SCALEWIDTH(15))
            make.left.width.equalTo(testingView1 )
            make.height.equalTo(SCALEWIDTH(70.5))
        }
       
        bottomContainerView.addSubview(button2)
        button2.snp.makeConstraints { make in
            make.top.equalTo(hisTestView2.snp.bottom)
            make.left.equalToSuperview().offset(SCALEWIDTH(42.5))
            make.width.equalTo(screenWidth - 85)
            make.height.equalTo(SCALEWIDTH(70.5))
        }
        
        
        //2
        bottomContainerView.addSubview(hisZhuanyeView)
        hisZhuanyeView.snp.makeConstraints { make in
            make.top.equalToSuperview()
            make.left.equalToSuperview().offset(screenWidth)
            make.height.equalTo(SCALEWIDTH(50))
            make.width.equalTo(screenWidth)
        }
        bottomContainerView.addSubview(hisZhuanyeLabel)
        hisZhuanyeLabel.snp.makeConstraints { make in
            make.left.equalToSuperview().offset(screenWidth + SCALEWIDTH(42.5))
            make.top.equalTo(hisIntroduceView.snp.bottom)
            make.width.equalTo(screenWidth - SCALEWIDTH(85))
        }
        
        //3
        bottomContainerView.addSubview(hisTestView)
        hisTestView.snp.makeConstraints { make in
            make.top.equalToSuperview()
            make.left.equalToSuperview().offset(screenWidth*2)
            make.height.equalTo(SCALEWIDTH(50))
            make.width.equalTo(screenWidth)
        }
        
        bottomContainerView.addSubview(guahaoqudaoBack)
        guahaoqudaoBack.snp.makeConstraints { make in
            make.top.equalTo(hisIntroduceLabel.snp.bottom).offset(SCALEWIDTH(15))
            make.left.equalToSuperview().offset(SCALEWIDTH(15))
            make.width.equalTo(screenWidth - SCALEWIDTH(30))
        }
        
        bottomContainerView.addSubview(testingView)
        testingView.snp.makeConstraints { make in
            make.top.equalTo(hisTestView.snp.bottom).offset(SCALEWIDTH(15))
            make.left.equalToSuperview().offset(screenWidth * 2 + SCALEWIDTH(39))
            make.right.equalToSuperview().offset(-SCALEWIDTH(59))
            make.height.equalTo(SCALEWIDTH(70.5))
        }
        
        bottomContainerView.addSubview(testedView)
        testedView.snp.makeConstraints { make in
            make.top.equalTo(testingView.snp.bottom).offset(SCALEWIDTH(15))
            make.left.equalToSuperview().offset(screenWidth * 2 + SCALEWIDTH(39))
            make.right.equalToSuperview().offset(-SCALEWIDTH(59))
            make.height.equalTo(SCALEWIDTH(70.5))
        }
        bottomContainerView.addSubview(button1)
        button1.snp.makeConstraints { make in
            make.top.equalTo(testingView.snp.bottom).offset(SCALEWIDTH(15))
            make.left.equalToSuperview().offset(screenWidth * 2 + SCALEWIDTH(39))
            make.right.equalToSuperview().offset(-SCALEWIDTH(59))
            make.height.equalTo(SCALEWIDTH(70.5))
        }
        bottomContainerView.addSubview(button3)
        button3.snp.makeConstraints { make in
            make.top.equalTo(hisTestView.snp.bottom).offset(SCALEWIDTH(15))
            make.left.equalToSuperview().offset(screenWidth * 2 + SCALEWIDTH(39))
            make.right.equalToSuperview().offset(-SCALEWIDTH(59))
            make.height.equalTo(SCALEWIDTH(70.5))
        }
    }
    
  
    private lazy var bottomScView:UIScrollView = {
        let vi = UIScrollView()
        vi.showsHorizontalScrollIndicator = false
        vi.showsVerticalScrollIndicator = false
        vi.isPagingEnabled = true
        vi.isUserInteractionEnabled = true
        vi.delegate = self
        vi.contentSize = CGSizeMake(screenWidth * 3, 1000)
        return vi
    }()
    
    private lazy var bottomContainerView:UIView = {
        let vi = UIView()
        vi.backgroundColor = .clear
        return vi
    }()
    private lazy var hisIntroduceView:UIView = {
        let vi = UIView()
        let imageV = UIImageView(image: UIImage(named: "doctorDetail_tips"))
        vi.addSubview(imageV)
        imageV.snp.makeConstraints { make in
            make.left.equalToSuperview().offset(SCALEWIDTH(24))
            make.centerY.equalToSuperview()
            make.size.equalTo(CGSize(width: SCALEWIDTH(10), height: SCALEWIDTH(10)))
        }
        
        let lab = UILabel()
        lab.font = .medium(16)
        lab.text = "我的介绍"
        lab.textColor = .rgba(54, 53, 56, 1)
        vi.addSubview(lab)
        lab.snp.makeConstraints { make in
            make.left.equalToSuperview().offset(SCALEWIDTH(42.5))
            make.centerY.equalToSuperview()
            make.height.equalTo(SCALEWIDTH(22.5))
        }
        return vi
    }()
    
    private lazy var hisZhuanyeView1:UIView = {
        let vi = UIView()
        let imageV = UIImageView(image: UIImage(named: "doctorDetail_tips"))
        vi.addSubview(imageV)
        imageV.snp.makeConstraints { make in
            make.left.equalToSuperview().offset(SCALEWIDTH(24))
            make.centerY.equalToSuperview()
            make.size.equalTo(CGSize(width: SCALEWIDTH(10), height: SCALEWIDTH(10)))
        }
        
        let lab = UILabel()
        lab.font = .medium(16)
        lab.text = "专业擅长"
        lab.textColor = .rgba(54, 53, 56, 1)
        vi.addSubview(lab)
        lab.snp.makeConstraints { make in
            make.left.equalToSuperview().offset(SCALEWIDTH(42.5))
            make.centerY.equalToSuperview()
            make.height.equalTo(SCALEWIDTH(22.5))
        }
        return vi
    }()
    private lazy var hisTestView1:UIView = {
        let vi = UIView()
        let imageV = UIImageView(image: UIImage(named: "doctorDetail_tips"))
        vi.addSubview(imageV)
        imageV.snp.makeConstraints { make in
            make.left.equalToSuperview().offset(SCALEWIDTH(24))
            make.centerY.equalToSuperview()
            make.size.equalTo(CGSize(width: SCALEWIDTH(10), height: SCALEWIDTH(10)))
        }
        
        let lab = UILabel()
        lab.font = .medium(16)
        lab.text = "临床试验"
        lab.textColor = .rgba(54, 53, 56, 1)
        vi.addSubview(lab)
        lab.snp.makeConstraints { make in
            make.left.equalToSuperview().offset(SCALEWIDTH(42.5))
            make.centerY.equalToSuperview()
            make.height.equalTo(SCALEWIDTH(22.5))
        }
        return vi
    }()
    
    
    private lazy var hisZhuanyeView:UIView = {
        let vi = UIView()
        let imageV = UIImageView(image: UIImage(named: "doctorDetail_tips"))
        vi.addSubview(imageV)
        imageV.snp.makeConstraints { make in
            make.left.equalToSuperview().offset(SCALEWIDTH(24))
            make.centerY.equalToSuperview()
            make.size.equalTo(CGSize(width: SCALEWIDTH(10), height: SCALEWIDTH(10)))
        }
        
        let lab = UILabel()
        lab.font = .medium(16)
        lab.text = "专业擅长"
        lab.textColor = .rgba(54, 53, 56, 1)
        vi.addSubview(lab)
        lab.snp.makeConstraints { make in
            make.left.equalToSuperview().offset(SCALEWIDTH(42.5))
            make.centerY.equalToSuperview()
            make.height.equalTo(SCALEWIDTH(22.5))
        }
        return vi
    }()
    private lazy var hisTestView:UIView = {
        let vi = UIView()
        let imageV = UIImageView(image: UIImage(named: "doctorDetail_tips"))
        vi.addSubview(imageV)
        imageV.snp.makeConstraints { make in
            make.left.equalToSuperview().offset(SCALEWIDTH(24))
            make.centerY.equalToSuperview()
            make.size.equalTo(CGSize(width: SCALEWIDTH(10), height: SCALEWIDTH(10)))
        }
        
        let lab = UILabel()
        lab.font = .medium(16)
        lab.text = "临床试验"
        lab.textColor = .rgba(54, 53, 56, 1)
        vi.addSubview(lab)
        lab.snp.makeConstraints { make in
            make.left.equalToSuperview().offset(SCALEWIDTH(42.5))
            make.centerY.equalToSuperview()
            make.height.equalTo(SCALEWIDTH(22.5))
        }
        return vi
    }()
    lazy var hisIntroduceLabel:UILabel = {
        let cont = UILabel()
        cont.font = .regular(14)
        cont.numberOfLines = 0
        cont.text = ""
        cont.textColor = .rgba(76, 76, 76, 1)
        return cont
    }()
    lazy var hisZhuanyeLabel1:UILabel = {
        let cont = UILabel()
        cont.font = .regular(14)
        cont.numberOfLines = 0
        cont.text = ""
        cont.textColor = .rgba(76, 76, 76, 1)
        return cont
    }()
    lazy var hisZhuanyeLabel:UILabel = {
        let cont = UILabel()
        cont.font = .regular(14)
        cont.numberOfLines = 0
        cont.text = ""
        cont.textColor = .rgba(76, 76, 76, 1)
        return cont
    }()
    private lazy var guahaoqudaoBack:UIView = {
        let vi = UIView()
        vi.backgroundColor = .white
        vi.layer.shadowColor = RGBA(r: 241, g: 241, b: 241, a: 0.5).cgColor
        vi.layer.shadowOffset = CGSize(width: 2, height: 2)
        vi.layer.shadowRadius = 4.5
        vi.layer.shadowOpacity = 1
        return vi
    }()
    
    private lazy var testingView:UIView = {
        let vi = UIView()
        vi.backgroundColor = .white
        vi.layer.shadowColor = RGBA(r: 241, g: 241, b: 241, a: 0.5).cgColor
        vi.layer.shadowOffset = CGSize(width: 2, height: 2)
        vi.layer.shadowRadius = 4.5
        vi.layer.shadowOpacity = 1
        
        let imagev = UIImageView(image: UIImage(named: "doctorDetail_testingleft"))
        vi.addSubview(imagev)
        imagev.snp.makeConstraints { make in
            make.left.equalToSuperview().offset(SCALEWIDTH(17))
            make.centerY.equalToSuperview()
            make.size.equalTo(CGSizeMake(SCALEWIDTH(40.5), SCALEWIDTH(40.5)))
        }
        
        let lab = UILabel()
        lab.font = .medium(14)
        lab.textColor = .rgba(51, 51, 51,1)
        lab.text = "正在进行中的临床试验"
        vi.addSubview(lab)
        lab.snp.makeConstraints { make in
            make.top.equalTo(imagev.snp.top)
            make.height.equalTo(SCALEWIDTH(20))
            make.left.equalTo(imagev.snp.right).offset(SCALEWIDTH(13))
        }
        
        let numl = UILabel()
        numl.font = .medium(14)
        numl.textColor = .rgba(51, 51, 51,1)
        numl.text = ""
        vi.addSubview(numl)
        numl.snp.makeConstraints { make in
            make.top.equalTo(lab.snp.bottom).offset(SCALEWIDTH(3))
            make.height.equalTo(SCALEWIDTH(17))
            make.left.equalTo(imagev.snp.right).offset(SCALEWIDTH(13))
        }
        hNum = numl
        let imagev2 = UIImageView(image: UIImage(named: "doctorDetail_testingright"))
        vi.addSubview(imagev2)
        imagev2.snp.makeConstraints { make in
            make.right.top.equalToSuperview()
            make.size.equalTo(CGSizeMake(SCALEWIDTH(47), SCALEWIDTH(47)))
        }
        
        return vi
    }()
    
    private lazy var testedView:UIView = {
        let vi = UIView()
        vi.backgroundColor = .white
        vi.layer.shadowColor = RGBA(r: 241, g: 241, b: 241, a: 0.5).cgColor
        vi.layer.shadowOffset = CGSize(width: 2, height: 2)
        vi.layer.shadowRadius = 4.5
        vi.layer.shadowOpacity = 1
        
        let imagev = UIImageView(image: UIImage(named: "doctorDetail_testedleft"))
        vi.addSubview(imagev)
        imagev.snp.makeConstraints { make in
            make.left.equalToSuperview().offset(SCALEWIDTH(17))
            make.centerY.equalToSuperview()
            make.size.equalTo(CGSizeMake(SCALEWIDTH(40.5), SCALEWIDTH(40.5)))
        }
        
        let lab = UILabel()
        lab.font = .medium(14)
        lab.textColor = .rgba(51, 51, 51,1)
        lab.text = "已完成的临床试验"
        vi.addSubview(lab)
        lab.snp.makeConstraints { make in
            make.top.equalTo(imagev.snp.top)
            make.height.equalTo(SCALEWIDTH(20))
            make.left.equalTo(imagev.snp.right).offset(SCALEWIDTH(13))
        }
        
        let numl = UILabel()
        numl.font = .medium(14)
        numl.textColor = .rgba(51, 51, 51,1)
        numl.text = ""
        vi.addSubview(numl)
        numl.snp.makeConstraints { make in
            make.top.equalTo(lab.snp.bottom).offset(SCALEWIDTH(3))
            make.height.equalTo(SCALEWIDTH(17))
            make.left.equalTo(imagev.snp.right).offset(SCALEWIDTH(13))
        }
        hsNum = numl
        let imagev2 = UIImageView(image: UIImage(named: "doctorDetail_testedright"))
        vi.addSubview(imagev2)
        imagev2.snp.makeConstraints { make in
            make.right.top.equalToSuperview()
            make.size.equalTo(CGSizeMake(SCALEWIDTH(47), SCALEWIDTH(47)))
        }
  
        return vi
    }()
    
    private lazy var hisTestView2:UIView = {
        let vi = UIView()
        let imageV = UIImageView(image: UIImage(named: "doctorDetail_tips"))
        vi.addSubview(imageV)
        imageV.snp.makeConstraints { make in
            make.left.equalToSuperview().offset(SCALEWIDTH(24))
            make.centerY.equalToSuperview()
            make.size.equalTo(CGSize(width: SCALEWIDTH(10), height: SCALEWIDTH(10)))
        }
        
        let lab = UILabel()
        lab.font = .medium(16)
        lab.text = "临床试验"
        lab.textColor = .rgba(54, 53, 56, 1)
        vi.addSubview(lab)
        lab.snp.makeConstraints { make in
            make.left.equalToSuperview().offset(SCALEWIDTH(42.5))
            make.centerY.equalToSuperview()
            make.height.equalTo(SCALEWIDTH(22.5))
        }
        return vi
    }()
    
    private lazy var testingView1:UIView = {
        let vi = UIView()
        vi.backgroundColor = .white
        vi.layer.shadowColor = RGBA(r: 241, g: 241, b: 241, a: 0.5).cgColor
        vi.layer.shadowOffset = CGSize(width: 2, height: 2)
        vi.layer.shadowRadius = 4.5
        vi.layer.shadowOpacity = 1
        
        let imagev = UIImageView(image: UIImage(named: "doctorDetail_testingleft"))
        vi.addSubview(imagev)
        imagev.snp.makeConstraints { make in
            make.left.equalToSuperview().offset(SCALEWIDTH(17))
            make.centerY.equalToSuperview()
            make.size.equalTo(CGSizeMake(SCALEWIDTH(40.5), SCALEWIDTH(40.5)))
        }
        
        let lab = UILabel()
        lab.font = .medium(14)
        lab.textColor = .rgba(51, 51, 51,1)
        lab.text = "正在进行中的临床试验"
        vi.addSubview(lab)
        lab.snp.makeConstraints { make in
            make.top.equalTo(imagev.snp.top)
            make.height.equalTo(SCALEWIDTH(20))
            make.left.equalTo(imagev.snp.right).offset(SCALEWIDTH(13))
        }
        
        let numl = UILabel()
        numl.font = .medium(14)
        numl.textColor = .rgba(51, 51, 51,1)
        numl.text = ""
        vi.addSubview(numl)
        numl.snp.makeConstraints { make in
            make.top.equalTo(lab.snp.bottom).offset(SCALEWIDTH(3))
            make.height.equalTo(SCALEWIDTH(17))
            make.left.equalTo(imagev.snp.right).offset(SCALEWIDTH(13))
        }
        h1Num = numl
        let imagev2 = UIImageView(image: UIImage(named: "doctorDetail_testingright"))
        vi.addSubview(imagev2)
        imagev2.snp.makeConstraints { make in
            make.right.top.equalToSuperview()
            make.size.equalTo(CGSizeMake(SCALEWIDTH(47), SCALEWIDTH(47)))
        }

        return vi
    }()
    
    private lazy var testedView1:UIView = {
        let vi = UIView()
        vi.backgroundColor = .white
        vi.layer.shadowColor = RGBA(r: 241, g: 241, b: 241, a: 0.5).cgColor
        vi.layer.shadowOffset = CGSize(width: 2, height: 2)
        vi.layer.shadowRadius = 4.5
        vi.layer.shadowOpacity = 1
        
        let imagev = UIImageView(image: UIImage(named: "doctorDetail_testedleft"))
        vi.addSubview(imagev)
        imagev.snp.makeConstraints { make in
            make.left.equalToSuperview().offset(SCALEWIDTH(17))
            make.centerY.equalToSuperview()
            make.size.equalTo(CGSizeMake(SCALEWIDTH(40.5), SCALEWIDTH(40.5)))
        }
        
        let lab = UILabel()
        lab.font = .medium(14)
        lab.textColor = .rgba(51, 51, 51,1)
        lab.text = "已完成的临床试验"
        vi.addSubview(lab)
        lab.snp.makeConstraints { make in
            make.top.equalTo(imagev.snp.top)
            make.height.equalTo(SCALEWIDTH(20))
            make.left.equalTo(imagev.snp.right).offset(SCALEWIDTH(13))
        }
        
        let numl = UILabel()
        numl.font = .medium(14)
        numl.textColor = .rgba(51, 51, 51,1)
        numl.text = ""
        vi.addSubview(numl)
        numl.snp.makeConstraints { make in
            make.top.equalTo(lab.snp.bottom).offset(SCALEWIDTH(3))
            make.height.equalTo(SCALEWIDTH(17))
            make.left.equalTo(imagev.snp.right).offset(SCALEWIDTH(13))
        }
        hs1Num = numl
        let imagev2 = UIImageView(image: UIImage(named: "doctorDetail_testedright"))
        vi.addSubview(imagev2)
        imagev2.snp.makeConstraints { make in
            make.right.top.equalToSuperview()
            make.size.equalTo(CGSizeMake(SCALEWIDTH(47), SCALEWIDTH(47)))
        }
        return vi
    }()
    private lazy var button1:UIButton = {
        let btn = UIButton()
//        btn.setBackgroundColor(color: .red, forState:.normal)
        btn.addTarget(self, action: #selector(clickButton(_:)), for: .touchUpInside)
        return btn
    }()
    
    private lazy var button:UIButton = {
        let btn = UIButton()
//        btn.setBackgroundColor(color: .red, forState:.normal)
        btn.addTarget(self, action: #selector(clickButton(_:)), for: .touchUpInside)
        return btn
    }()
    
    private lazy var button2:UIButton = {
        let btn = UIButton()
//        btn.setBackgroundColor(color: .red, forState:.normal)
        btn.addTarget(self, action: #selector(clickButton(_:)), for: .touchUpInside)
        return btn
    }()
    
    private lazy var button3:UIButton = {
        let btn = UIButton()
//        btn.setBackgroundColor(color: .red, forState:.normal)
        btn.addTarget(self, action: #selector(clickButton(_:)), for: .touchUpInside)
        return btn
    }()
    @objc private func clickButton(_ sneder: UIButton) {
        
        let vc = H5ViewController()
        vc.title = "临床实验"
        let token = MYGUserManager.getUser()?.verification_token ?? ""
        vc.url = "http://h5-dev.medataplus.com/#/pages/clinicalDetail/clinicalDetail?token=\(token)"
        UIViewController.currentViewController?.navigationController?.pushViewController(vc)
    }
   
    
    override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
        guard let hitView = super.hitTest(point, with: event) else { return nil }
        if let scrollView = hitView as? UIScrollView {
//            let hitView = scrollView.hitTest(pointInScrollView, with: event)
            // 处理 hitView 事件
            let viewPoint: CGPoint = self.convert(point, to: self.bottomScView)
            if hitView == self.bottomScView {
                for sub in hitView.subviews {
                    if  sub == self.bottomContainerView {
                        for subs in sub.subviews {
                            if subs is UIButton {
                                if subs == button {
                                    let isContains = subs.frame.contains(viewPoint)
                                    if isContains {
                                        return button
                                    }
                                }else if subs == button1 {
                                    let isContains = subs.frame.contains(viewPoint)
                                    if isContains {
                                        return button1
                                    }
                                }else if subs == button2 {
                                    let isContains = subs.frame.contains(viewPoint)
                                    if isContains {
                                        return button2
                                    }
                                }else if subs == button3 {
                                    let isContains = subs.frame.contains(viewPoint)
                                    if isContains {
                                        return button3
                                    }
                                }
    
                            }
                        }
    
    
                    }
    
                }
            }
        }
        return hitView
    }
    
//    override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
//        guard let hitView = super.hitTest(point, with: event) else { return nil }
//        
//        let viewPoint: CGPoint = self.convert(point, to: self)
//        if hitView == self.bottomScView {
//            for sub in hitView.subviews {
//                if  sub == self.bottomContainerView {
//                    for subs in sub.subviews {
//                        if subs is UIButton {
//                            if subs == butoon {
//                                let isContains = subs.frame.contains(viewPoint)
//                                if isContains {
//                                    return butoon
//                                }
//                            }
//                            
//                        }
//                    }
//                    
//                    
//                }
//                    
//            }
//        }
//        return hitView
//    }
}

extension MYGAboutMineView:UIScrollViewDelegate{
    
    func scrollViewDidScroll(_ scrollView: UIScrollView) {
        if scrollView.contentOffset.y < 0 || scrollView.contentOffset.y > 0{
            scrollView.contentOffset.y = 0
        }
        if scrollView.contentOffset.x <= 0 {
            scrollView.contentOffset.x = 0
//            scrollLineView.snp.updateConstraints { make in
//                make.left.equalToSuperview().offset(0)
//            }
            self.selectTypeBlock?(0)
        }
        if scrollView.contentOffset.x > screenWidth * 2 {
            scrollView.contentOffset.x = screenWidth * 2
        }
        
        if scrollView.contentOffset.x == screenWidth {
//            scrollLineView.snp.updateConstraints { make in
//                make.left.equalToSuperview().offset(screenWidth/3)
//            }
            self.selectTypeBlock?(1)
        }
        if scrollView.contentOffset.x == screenWidth*2 {
//            scrollLineView.snp.updateConstraints { make in
//                make.left.equalToSuperview().offset(screenWidth/3*2)
//            }
            self.selectTypeBlock?(2)
        }
    }
}
